package com.melodyframe.tableland.engine.model.map;

import com.melodyframe.tableland.engine.model.common.Asset;

public abstract class AbstractResource<T extends Asset> implements Resource<T> {

    private T valueAssert;
    private T collectionAssert;

    public AbstractResource() {
    }

    public AbstractResource(int value, int collection) {
        this.setValueAssert(value);
        this.setCollectionAssert(collection);
    }

    public abstract Class<T> getAssetType();

    @Override
    public T getValue() {
        return valueAssert;
    }

    @Override
    public T collection() {
        return collectionAssert;
    }

    public void setValueAssert(int value) {
        try {
            T valueAssert = getAssetType().newInstance();
            valueAssert.setValue(value);
            this.setValueAssert(valueAssert);
        } catch (Exception e) {
        }
    }

    public void setValueAssert(T valueAssert) {
        this.valueAssert = valueAssert;
    }

    public void setCollectionAssert(int collection) {
        try {
            T collectionAssert = getAssetType().newInstance();
            collectionAssert.setValue(collection);
            this.setCollectionAssert(collectionAssert);
        } catch (Exception e) {
        }
    }

    public void setCollectionAssert(T collectionAssert) {
        this.collectionAssert = collectionAssert;
    }

}
